Repository navigation
fix(id): reconnect resume retains its baseline; host restores viewport (#12648) - #12704
Merged
Merged
Conversation
A resume token's retained baseline records the viewport that produced it, but joined() initialized every connection's viewport to None, so the first resumed view rendered at the program's default size and the shape-checked consume in send_view always missed for a baseline retained at a non-default viewport. The resume was silently a full view every time. BaselineCache gains a participant-bound, non-consuming peek (viewport_for); joined() restores the viewport from the retained baseline before the first send_view consumes the one-shot token. take_matching still performs the shape-checked consume, and a miss still falls back to a full view. The wrong-viewport test is replaced by the regression this behavior needs: a_resume_token_restores_the_viewport_before_catching_up (the test PR #12246 wrote but never ran), plus a unit test pinning that the peek does not consume. Ported from PR #12246 commit 3751be8, adapted to the post-#12242 session shape. Refs #12648
The browser never participated in resume: world.ts did not declare resume_token on the frame type, never adopted the token view frames carry, never offered one in the join frame, and connect() cleared the rendered surface and revision on every reconnect — so even a host willing to send a catch-up patch had nothing to patch against. Token, surface, and revision now move as one unit: adopted together from every applied view (JSON and MessagePack paths), offered in the join frame when the unit is complete, and retained across reconnects. A same-size resize no longer goes out on a resumable reconnect (it resets the host's retained baseline); a real viewport change or a forced resync drops all three together and asks for a full view. Host view (the read-only HTTP path) clears the token with the surface, since its renders are not session baselines. New world-resume.test.ts carries the coverage #12648 names: a catch-up patch applies after a reconnect with no intervening resize, and a viewport change drops the unit. Adapted from PR #12246 commit 2b9428d to the screen_msgpack negotiation that landed in #12242. Refs #12648
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 51 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #12648
What
Reconnect resume was degraded at both ends, on the v1/JSON path and the negotiated MessagePack path alike:
web/src/world.ts): the browser never participated in resume — it didn't declareresume_tokenon the frame type, never adopted the token view frames carry, never offered one at join, andconnect()cleared the rendered surface/revision on every reconnect.id-worldsworld_session):joined()initialized every connection's viewport toNoneand never restored it from the retained baseline, so the first resumed view rendered at the program default size and the shape-checked consume insend_viewmissed for every baseline retained at a non-default viewport.This ports the two fix commits from the superseded PR #12246 (2b9428d browser, 3751be8 host), adapted to the post-#12242 shape (screen_msgpack negotiation instead of the v2 route), and — unlike #12246 — actually runs the regression coverage.
Host
BaselineCache::viewport_for: a participant-bound, non-consuming peek at the viewport a live token's baseline was retained at.take_matchingstill performs the one-shot, shape-checked consume; a miss still falls back to a full view, and join authorization is untouched.joined()restores the connection viewport from the retained baseline before the firstsend_view.a_wrong_viewport_resume_token_falls_back_to_a_full_viewtest is replaced bya_resume_token_restores_the_viewport_before_catching_up(WideScreen gains the step counter so a real catch-up patch exists to assert on), plus a unit test pinning that the peek does not consume and is participant-bound.Browser
web/src/world-resume.test.ts: a catch-up patch applies after a reconnect with no intervening resize; a viewport change drops the unit.Verification (laptop, pkgs/id nix dev shell)
Failing first, tests-only: the new host test failed at the catch-up-patch assertion (full view instead of a patch) and the new browser test failed on the missing join
resume_token; theviewport_forunit test passed against the peek alone, isolating the missing restore.With the fix:
cargo test -p id-worlds --lib resume— 14 passed, 0 failed.cargo test -p id-worlds --lib(full) — 910 passed, 1 failed:shell_contract::tests::the_contracts_required_fields_are_exactly_what_the_host_requires(join.device_inputnull disagreement). Pre-existing on pristine main — reproduced identically in a clean worktree of origin/main (bff67fd) running only that test; filed as id: shell contract test fails on main — join.device_input null disagreement between contract and host #12703.bun run test(web unit, full) — 43 files, 881 passed, 9 skipped (879 baseline + the 2 new tests).bun run typecheck— clean. Biome format + lint on the touched files — clean.cargo fmt --check— clean for the touched files (pre-existing diffs in id-core/id-store files untouched here). Clippy on id-worlds — no warnings at the touched locations.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.